
#include <iostream>

#include "subject.h"
#include "observer.h"

void Subject::Attach(std::shared_ptr<Observer> obv)
{
    if (obv) {
        obvs_.push_back(obv);
    }
}

void Subject::Detach(std::shared_ptr<Observer> obv)
{
    for (auto it = obvs_.begin(); it != obvs_.end();) {
        if (obv.get() == (*it).get()) {
            obvs_.erase(it);
        }
    }
}

void Subject::Notify()
{
    for (auto obv : obvs_) {
        obv->Update();
    }
}

void SubjectA::SetStatus(std::string &status)
{
    status_ = status;
}

std::string SubjectA::GetStatus()
{
    return status_;
}

void SubjectB::SetStatus(std::string &status)
{
    status_ = status;
}

std::string SubjectB::GetStatus()
{
    return status_;
}

